const Router = require("koa-router");
const { Like } = require("@models/like");
const { Auth } = require("../../../middlewares/auth");

const {
  LikeValidator,
  newLikeValidator,
} = require("../../validator/validator");
const { ScopeType } = require("../../../lib/enum");
const router = new Router();

router.post(
  "/v1/like/onLike",
  new Auth(ScopeType.USER).m,
  async (ctx, next) => {
    const v = await new LikeValidator().validate(ctx, { id: "artId" });
    const res = await Like.onLike(
      v.get("body.artId"),
      v.get("body.type"),
      ctx.auth.uId
    );
    throw new global.errs.Success();
  }
);

router.post(
  "/v1/like/disLike",
  new Auth(ScopeType.USER).m,
  async (ctx, next) => {
    const v = await new LikeValidator().validate(ctx,{id:'artId'});
    const res = await Like.disLike(
      v.get("body.artId"),
      v.get("body.type"),
      ctx.auth.uId
    );
    throw new global.errs.Success();
  }
);

module.exports = router;
